﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using MbUnit.Framework;
using Netkk.Common.Models;
using Netkk.Library.Repositories;
using Netkk.Library.Services;
using Netkk.Library.Validation;
using System;

namespace Netkk.Tests.Links
{
    [TestFixture]
    public class NewsTest
    {
        private INewsService newsService;

        [SetUp]
        public void Startup()
        {
            ModelStateDictionary modelStateDictionary = new ModelStateDictionary();
            IValidationDictionary validationDictionary = new ModelStateWrapper(modelStateDictionary);
            newsService = new NewsService(validationDictionary, new NewsRepository());
        }

        [TearDown]
        public void Shutdown()
        {
        }

        [Test]
        public void Should_Return_More_Than_Zero_Future_News()
        {
            IEnumerable<News> news = newsService.GetNextNews();

            Assert.GreaterThan(news.Count(), 0);
        }

        [Test]
        public void Should_Return_More_Than_Zero_Past_News()
        {
            IEnumerable<News> news = newsService.GetPastNews();

            Assert.GreaterThan(news.Count(), 0);
        }

        [Test]
        [Row("{6051003f-ceb0-4699-adfe-155dcd938ffc}")]
        [Row("{e3adad37-1127-4947-9a37-bc0326da1e37}")]
        public void Schould_Return_A_Valid_News_From_A_Given_Id(string guid)
        {
            News news = newsService.GetNewsById(new Guid(guid));

            Assert.IsNotNull(news);
        }

        [Test]
        [Row("{77777777-8a19-4df4-b36a-4940fdb634d4}")]
        [Row("{0bd0689e-7777-496c-9c30-8b88dce0b0ac}")]
        public void Schould_Not_Return_A_Valid_News_From_A_Given_Id(string guid)
        {
            News news = newsService.GetNewsById(new Guid(guid));

            Assert.IsNull(news);
        }

        //[Test]
        //public void Create_Select_And_Delete_A_Link()
        //{
        //    Guid linkId = Guid.NewGuid();
        //    Link link = new Link
        //    {
        //        Id = linkId,
        //        Name = "TestLinkName",
        //        Category = "TestLinkCategory",
        //        Description = "TestLinkDescription",
        //        Order = 999,
        //        Url = "TestLinkUrl"
        //    };

        //    Assert.IsTrue(newsService.SaveLink(link), "Benutzer wurde nicht erstellt");

        //    link = newsService.GetLinkById(linkId);

        //    Assert.IsNotNull(link, "Erstelter Benutzer wurde nicht gefunden");

        //    newsService.DeleteLink(link);

        //    link = newsService.GetLinkById(linkId);

        //    Assert.IsNull(link, "Erstellter Benutzer wurde nicht gelöscht");
        //}
    }
}
